package com.monitor.web.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

/**
 * @Author tanlian
 * @Date 2018/9/26 13:46
 * @Desc
 */
@Configuration
public class RedisConfig {

    @Value("${jedis.maxIdle}")
    private Integer maxIdle;

    @Value("${jedis.maxTotal}")
    private Integer maxTotal;

    @Value("${jedis.minIdle}")
    private Integer minIdle;

    @Value("${jedis.host}")
    private String host;

    @Value("${jedis.port}")
    private Integer port;

    @Value("${jedis.timeout}")
    private Integer timeout;


    @Value("${jedis.password}")
    private String password;



    @Bean
    public JedisPool initPool(){
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxIdle(maxIdle);
        config.setMaxTotal(maxTotal);
        config.setMinIdle(minIdle);

        /** 还有些其他参数 **/
        return new JedisPool(config, host , port , timeout,password);

    }


}
